﻿using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using Omniscient.Foundation.Security;

namespace Omniscient.TimeTracker.BusinessModel.Security
{
    [ServiceContract]
    public interface ISecurityService
    {
        [OperationContract]
        [FaultContract(typeof(ValidationException))]
        SecurePrincipal GetAuthenticatedUser(string username, string password);
    }
    
    [Serializable]
    public class ValidationException : ApplicationException
    {
        private string _customMessage;

        public string CustomMessage
        {
            get { return _customMessage; }
            set { _customMessage = value; }
        }

        public ValidationException(string message)
        {
            _customMessage = message;
        }

        protected ValidationException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _customMessage = info.GetString("_customMessage");
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("_customMessage", _customMessage);
        }
    }
}
